package com.demo.crm.security.access.matcher;

import com.demo.crm.model.UserToken;

import java.util.Set;

/**
 * 只要有一个匹配即可
 *
 * @author tanshuai
 */
public class OrMatcher implements AccessMatcher {

    public boolean match(UserToken userToken, Set<String> allows) {
        Set<String> authorities = userToken.getAuthorities();
        for (String authority : authorities) {
            for (String allow : allows) {
                if (authority.equals(allow)) {
                    return true;
                }
            }
        }
        return false;
    }
}
